fix: resolve Pi CLI via process.argv[1] for Nix and non-standard installs#520
fix: resolve Pi CLI via process.argv[1] for Nix and non-standard installs#520chenxin-yan wants to merge 1 commit into
Conversation
…alls When taskplane runs as a Pi extension, the current process is already 'node dist/cli.js' — so process.argv[1] is exactly the CLI entrypoint we need to spawn worker agents. The previous implementation only checked npm global roots and static paths, none of which cover Nix (where pi lives in the Nix store, not in any npm prefix). The process.argv[1] candidate: - Is always correct when running inside Pi (it IS the file we're looking for) - Requires no subprocess overhead unlike npm root -g - Covers any non-standard install: Nix, custom node wrappers, symlinked bins - Is consistent with how resolveTaskplanePackageFile() already uses process.argv[1] to locate taskplane's own package files Also adds ~/.nix-profile and /run/current-system/sw as static Nix fallbacks for cases where process.argv[1] is a shell wrapper rather than cli.js directly.
|
@chenxin-yan — thank you so much for this contribution, and apologies for letting it sit for a month. Reading your PR alongside the current state of // extensions/taskplane/path-resolver.ts:235
const piPath = process.argv[1] || "";It landed via a slightly different code path during the broader Pi So I'm going to:
For other Nix users landing here: Taskplane Thank you again for taking the time to file and prepare a PR — that combination is genuinely rare and made this a much easier confirmation than it would have been from a symptom-only report. Hope you'll consider contributing again. 🙏 |
Fixes #519
Problem
resolvePiCliPath()fails to find the Pi CLI whenpiis installed via Nix. Nix places packages in the Nix store (/nix/store/<hash>-pi-coding-agent-<ver>/), not in any npm global prefix, so none of the existing resolution candidates match. Worker agents never spawn and tasks fail immediately.Fix
When taskplane runs as a Pi extension, the current process is already
node dist/cli.js— soprocess.argv[1]is the exact entrypoint we need. Adding it as the first candidate inresolvePiCliPath()solves the problem with zero subprocess overhead and covers any non-standard install (Nix, custom node wrappers, symlinked binaries, etc.).This technique is already used in
resolveTaskplanePackageFile()(candidate 8) to locate taskplane's own package files — this PR applies it consistently toresolvePiCliPath()as well.Also adds
~/.nix-profileand/run/current-system/swas static fallbacks for the edge case whereprocess.argv[1]is a shell wrapper rather thancli.jsdirectly.Changes
extensions/taskplane/path-resolver.ts: addprocess.argv[1]as candidate 1 inresolvePiCliPath(); add Nix static paths; update doc comment with new resolution orderTesting
Verified the reproduction case: Pi installed via
pkgs.pi-coding-agent(nixpkgs, nix-darwin), taskplane loaded viapi -e npm:taskplane. Before this fix: worker spawn fails immediately. After:process.argv[1]resolves to the Nix storecli.jspath and workers launch correctly.